package com.bootdo.appsystem.service.impl;

import com.bootdo.app.utils.redis.AppRedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bootdo.appsystem.dao.BannerDao;
import com.bootdo.appsystem.domain.BannerDO;
import com.bootdo.appsystem.service.BannerService;



@Service
public class BannerServiceImpl implements BannerService {
	@Autowired
	private BannerDao bannerDao;
	
	@Override
	public BannerDO get(Integer id){
		return bannerDao.get(id);
	}
	
	@Override
	public List<BannerDO> list(Map<String, Object> map){
		return bannerDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return bannerDao.count(map);
	}
	
	@Override
	public int save(BannerDO banner){
		return bannerDao.save(banner);
	}
	
	@Override
	public int update(BannerDO banner){
		return bannerDao.update(banner);
	}
	
	@Override
	public int remove(Integer id){
		return bannerDao.remove(id);
	}
	
	@Override
	public int batchRemove(Integer[] ids){
		return bannerDao.batchRemove(ids);
	}

	@Override
	public List<BannerDO> getIndexList(Integer i) {
        List<BannerDO> indexBanner = null;
        indexBanner = AppRedisUtil.get("indexBanner" + i);
        if (indexBanner == null) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("status" , 1);
            map.put("isdeform" , i);
            indexBanner = this.list(map);
            AppRedisUtil.put("indexBanner"  + i,indexBanner);
        }
        return indexBanner;
	}

}













